# Create your views here.
# 全局配置
from rest_framework.decorators import api_view

from Task.task import scheduler_plan
#from Task.taskList import update_enterpise_task
from Task.taskList import update_enterpise_task, update_gasStation_task, updateWxwrokGroup, updateWxwrokGroupMemberd
from app.models import SalemanTeam, Saleman, CustomerServicer, Enterprise, GasStation, GasStationOnline, \
    GasStationPayments, GasStationTrain, GasStationOffline, WxworkGroupy, GasStationDayReport

from rest_framework.decorators import api_view
from rest_framework.response import Response

class ThemeSetting(object):

    enable_themes = True  # 启用主题
    use_bootswatch = True  # 启用多主题风格,如果主题不能多变可以跟踪源码看

class CustomView(object):
    site_title = 'AI油站管理辅助系统'  # 网页头部导航
    site_footer = 'AI油站管理辅助系统'  # 底部版权
    meun_style = 'accordion'  # 左侧导航折叠筐
# 自定义菜单
    def get_site_menu(self):
        return [
            {
                'title': '人员管理',
                'icon': 'fa fa-bars',       # Font Awesome图标
                'menus':(
                    {
                        'title': '业务团队',
                        'icon': 'fa fa-bug',
                        'url': self.get_model_url(SalemanTeam, 'changelist')

                    },
                    {
                        'title': '业务人员',
                        'icon': 'fa fa-envelope-o',
                        'url': self.get_model_url(Saleman, 'changelist'),
                    },
                    {
                        'title': '客服人员',
                        'icon': 'fa fa-envelope-o',
                        'url': self.get_model_url(CustomerServicer, 'changelist'),
                    }
                )
            }
            ,{
                'title': '油站管理',
                'icon': 'fa fa-bars',       # Font Awesome图标
                'menus':(
                    {
                        'title': '油企管理',
                        'icon': 'fa fa-bug',
                        'url': self.get_model_url(Enterprise, 'changelist')

                    },
                    {
                        'title': '油站管理',
                        'icon': 'fa fa-envelope-o',
                        'url': self.get_model_url(GasStation, 'changelist'),
                    },
                    {
                        'title': '上线时间',
                        'icon': 'fa fa-envelope-o',
                        'url': self.get_model_url(GasStationOnline, 'changelist'),
                    },
                    {
                        'title': '下线时间',
                        'icon': 'fa fa-envelope-o',
                        'url': self.get_model_url(GasStationOffline, 'changelist'),
                    },
                    {
                        'title': '培训明细',
                        'icon': 'fa fa-envelope-o',
                        'url': self.get_model_url(GasStationTrain, 'changelist'),
                    },
                    {
                        'title': '付款明细',
                        'icon': 'fa fa-envelope-o',
                        'url': self.get_model_url(GasStationPayments, 'changelist'),
                    }
                    ,{
                        'title': '微信企业号',
                        'icon': 'fa fa-bug',
                        'url': self.get_model_url(WxworkGroupy, 'changelist')

                    }
                    , {
                        'title': '油站日报表',
                        'icon': 'fa fa-bug',
                        'url': self.get_model_url(GasStationDayReport, 'changelist')

                    }
                )
            }
        ]

@api_view(['GET', 'POST'])
def test(request, format=None):
    if request.method == 'GET':
        cookie= 'RK=GGi4TFofXv; ptcz=ed7596349d9abdb7acd2a08579b152f7bea7e8a2b010b9482ca8e174bbcbea4b; pgv_pvid=4590865652; wwrtx.c_gdpr=0; worknote_upgradeFlag1688851379198264=; qq_openid=35936AD63D30336DB3F1552AFD0B2B72; qq_access_token=AE896C4B3FF4EB81AED38A04D02DD4E0; qq_client_id=101487368; pac_uid=3_35936AD63D30336DB3F1552AFD0B2B72; xw_main_login=qq; tvfe_boss_uuid=c4303f2569135296; pt_sms_phone=189******53; Hm_lvt_9364e629af24cb52acc78b43e8c9f77d=1620187293,1620523423; iip=0; ptui_loginuin=179049114; open_id=35936AD63D30336DB3F1552AFD0B2B72; wwrtx.ref=direct; wwrtx.refid=01226365; wwrtx.ltype=1; wwrtx.cs_ind=; wwrtx.i18n_lan=zh; wwrtx.vid=1688851379198264; wxpay.corpid=1970325131445067; wxpay.vid=1688851379198264; ww_rtkey=6s89vqd; wwrtx.vst=XZAyaeKgtOF4riEfcugmcHSV_C5ntRqkyw81hfqCNo37nfwmLTgvI6eemrAnBukMpkMu9-btoSjakkKhCrg6zLnfmDxszYlJW7gF_APz0gbfir10kQ8jkV9aDLfpW0bXwBtOsYC27Gsx812MyfJ0VMq-RNsrkvve6fg2miA33nD8eFYpWiBTe6geHmiBQfkRGr_tXUisWv5h_izDI9BxP8E6xvI9pjkoP5uciaZYKe8HteSlIc5fgdOYipxn3uhQwaOQbCCoG1hUDFyFy_z0dA; wwrtx.d2st=a2045695; wwrtx.sid=8tV4XZLZFAtR-PfSlLv-3ZQET7S9NJ0IJbGEANHnzD-n5wcI_FZTozR7MtZksV8y'
        print('--------------------------------')
        # updateWxwrokGroup(cookie)
        updateWxwrokGroupMemberd(cookie)
        #update_gasStation_task()
        return Response({"code":1, "msg": "ok"})
    return Response({"code": 1, "msg": "please use get "})

